<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  
  
    <meta name="keywords" content="lnsix">
  
  
    <meta name="description" content="我的个人博客！">
  
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <title>
    Centos7上使用shell脚本一键安装部署lnmp |
    
    lnsix的个人博客</title>
  
    <link rel="shortcut icon" href="/favicon.ico">
  
  
<link rel="stylesheet" href="/css/style.css">

  
    
<link rel="stylesheet" href="/fancybox/jquery.fancybox.min.css">

  
  
<script src="/js/pace.min.js"></script>

<meta name="generator" content="Hexo 5.2.0"></head>

<body>
<main class="content">
  <section class="outer">
  <article id="drafts-Centos7上使用shell脚本一键安装部署lnmp" class="article article-type-drafts" itemscope
  itemprop="blogPost" data-scroll-reveal>

  <div class="article-inner">
    
    <header class="article-header">
      
  
    <h1 class="article-title" itemprop="name">
      Centos7上使用shell脚本一键安装部署lnmp
    </h1>
  
  




    </header>
    

    
    <div class="article-meta">
      <a href="/2020/11/19/Centos7%E4%B8%8A%E4%BD%BF%E7%94%A8shell%E8%84%9A%E6%9C%AC%E4%B8%80%E9%94%AE%E5%AE%89%E8%A3%85%E9%83%A8%E7%BD%B2lnmp/" class="article-date">
  <time datetime="2020-11-18T16:00:00.000Z" itemprop="datePublished">2020-11-19</time>
</a>
      
    </div>
    

    
    
<div class="tocbot"></div>

    

    <div class="article-entry" itemprop="articleBody">
      


      

      
      <h2 id="lnmp-sh"><a href="#lnmp-sh" class="headerlink" title="lnmp.sh"></a>lnmp.sh</h2><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br><span class="line">109</span><br><span class="line">110</span><br><span class="line">111</span><br><span class="line">112</span><br><span class="line">113</span><br><span class="line">114</span><br><span class="line">115</span><br><span class="line">116</span><br><span class="line">117</span><br><span class="line">118</span><br><span class="line">119</span><br><span class="line">120</span><br><span class="line">121</span><br><span class="line">122</span><br><span class="line">123</span><br><span class="line">124</span><br><span class="line">125</span><br><span class="line">126</span><br><span class="line">127</span><br><span class="line">128</span><br><span class="line">129</span><br><span class="line">130</span><br><span class="line">131</span><br><span class="line">132</span><br><span class="line">133</span><br><span class="line">134</span><br><span class="line">135</span><br><span class="line">136</span><br><span class="line">137</span><br><span class="line">138</span><br><span class="line">139</span><br><span class="line">140</span><br><span class="line">141</span><br><span class="line">142</span><br><span class="line">143</span><br><span class="line">144</span><br><span class="line">145</span><br><span class="line">146</span><br><span class="line">147</span><br><span class="line">148</span><br><span class="line">149</span><br><span class="line">150</span><br><span class="line">151</span><br><span class="line">152</span><br><span class="line">153</span><br><span class="line">154</span><br><span class="line">155</span><br><span class="line">156</span><br><span class="line">157</span><br><span class="line">158</span><br><span class="line">159</span><br><span class="line">160</span><br><span class="line">161</span><br><span class="line">162</span><br><span class="line">163</span><br><span class="line">164</span><br><span class="line">165</span><br><span class="line">166</span><br><span class="line">167</span><br><span class="line">168</span><br><span class="line">169</span><br><span class="line">170</span><br><span class="line">171</span><br><span class="line">172</span><br><span class="line">173</span><br><span class="line">174</span><br><span class="line">175</span><br><span class="line">176</span><br><span class="line">177</span><br><span class="line">178</span><br><span class="line">179</span><br><span class="line">180</span><br><span class="line">181</span><br><span class="line">182</span><br><span class="line">183</span><br><span class="line">184</span><br><span class="line">185</span><br><span class="line">186</span><br><span class="line">187</span><br><span class="line">188</span><br><span class="line">189</span><br><span class="line">190</span><br><span class="line">191</span><br><span class="line">192</span><br><span class="line">193</span><br><span class="line">194</span><br><span class="line">195</span><br><span class="line">196</span><br><span class="line">197</span><br><span class="line">198</span><br><span class="line">199</span><br><span class="line">200</span><br><span class="line">201</span><br><span class="line">202</span><br><span class="line">203</span><br><span class="line">204</span><br><span class="line">205</span><br><span class="line">206</span><br><span class="line">207</span><br><span class="line">208</span><br><span class="line">209</span><br><span class="line">210</span><br><span class="line">211</span><br><span class="line">212</span><br><span class="line">213</span><br><span class="line">214</span><br><span class="line">215</span><br></pre></td><td class="code"><pre><span class="line">#!&#x2F;bin&#x2F;bash</span><br><span class="line"># DATE：2018-10-17</span><br><span class="line">#this is a lnmp-install</span><br><span class="line"> </span><br><span class="line"># The Nginx service is being installed</span><br><span class="line">ROOT_ID&#x3D;0</span><br><span class="line">ML&#x3D;&#x2F;usr&#x2F;local&#x2F;src</span><br><span class="line">NGINX_ML&#x3D;&#x2F;usr&#x2F;local&#x2F;src&#x2F;nginx-1.12.2</span><br><span class="line">PML&#x3D;&#x2F;usr&#x2F;local&#x2F;src&#x2F;php5.6.27</span><br><span class="line">QD&#x3D;&#96;netstat -anpt | grep 80 | awk &#39;&#123;print $7&#125;&#39; | cut -d &quot;&#x2F;&quot; -f2 | cut -d &quot;:&quot; -f1&#96;</span><br><span class="line">ADDR&#x3D;&#96;ip a | grep eth0$ | awk &#39;&#123;print $2&#125;&#39; | cut -d &quot;&#x2F;&quot; -f1&#96;</span><br><span class="line">MMM&#x3D;&#96;netstat -anput | grep mysqld | awk &#39;&#123;print $4&#125;&#39; | cut -d &quot;:&quot; -f4&#96;</span><br><span class="line">MAR&#x3D;&#96;rpm -qa | grep mariadb&#96;</span><br><span class="line">cd $ML &amp;&amp; &#123;</span><br><span class="line">wget http:&#x2F;&#x2F;mirrors.aliyun.com&#x2F;repo&#x2F;Centos-7.repo &amp;&gt; &#x2F;dev&#x2F;null</span><br><span class="line">mv Centos-7.repo &#x2F;etc&#x2F;yum.repos.d&#x2F;Centos-Base.repo</span><br><span class="line">yum clean all &amp;&gt; &#x2F;dev&#x2F;null</span><br><span class="line">yum makecache &amp;&gt; &#x2F;dev&#x2F;null</span><br><span class="line">&#125;</span><br><span class="line"> </span><br><span class="line">if [ $? -eq 0 ]</span><br><span class="line">    then</span><br><span class="line">          echo &quot;Yum源更新完毕,开始安装！！！&quot;</span><br><span class="line">    else</span><br><span class="line">        echo &quot;Yum源error&quot;</span><br><span class="line">        exit 1</span><br><span class="line">fi</span><br><span class="line">echo &quot;Yum源配置成功&quot;</span><br><span class="line"> </span><br><span class="line">if [ &quot;$UID&quot; -eq &quot;$ROOT_ID&quot; ]</span><br><span class="line">        then</span><br><span class="line">               echo &quot;root用户运行中&quot; &amp;&amp; systemctl stop firewalld &amp;&amp; yum install -y gcc gcc-c++  pcre-devel zlib-devel openssl-devel &amp;&gt; &#x2F;dev&#x2F;null</span><br><span class="line">        else</span><br><span class="line">               echo &quot;请使用Root用户运行&quot;</span><br><span class="line">               exit 1</span><br><span class="line">fi</span><br><span class="line">echo &quot;依赖包安装完成！&quot;</span><br><span class="line">cd $ML || &#123;</span><br><span class="line">        echo &quot;进入目录失败！！！&quot;</span><br><span class="line">        exit 1</span><br><span class="line">&#125;</span><br><span class="line"> </span><br><span class="line">wget http:&#x2F;&#x2F;nginx.org&#x2F;download&#x2F;nginx-1.12.2.tar.gz &amp;&gt; &#x2F;dev&#x2F;null &amp;&amp; &#123;</span><br><span class="line">tar zxf nginx-1.12.2.tar.gz &amp;&amp; groupadd www &amp;&amp; useradd -g www www -s &#x2F;sbin&#x2F;nologin</span><br><span class="line">&#125;</span><br><span class="line">echo &quot;Nginx包下载成功&quot;</span><br><span class="line">cd $NGINX_ML &amp;&amp; &#123;</span><br><span class="line">    .&#x2F;configure --prefix&#x3D;&#x2F;usr&#x2F;local&#x2F;nginx --with-http_dav_module --with-http_stub_status_module --with-http_addition_module --with-http_sub_module --with-http_flv_module --with-http_mp4_module --with-http_ssl_module --with-http_gzip_static_module --user&#x3D;www --group&#x3D;www &amp;&gt; &#x2F;dev&#x2F;null &amp;&amp; make &amp;&gt; &#x2F;dev&#x2F;null &amp;&amp; make install &amp;&gt; &#x2F;dev&#x2F;null </span><br><span class="line">&#125;</span><br><span class="line"> </span><br><span class="line">if [ $? -eq &quot;0&quot; ]</span><br><span class="line">        then</span><br><span class="line">               ln -s &#x2F;usr&#x2F;local&#x2F;nginx&#x2F;sbin&#x2F;nginx &#x2F;usr&#x2F;local&#x2F;sbin ;nginx &amp;&amp; echo &quot;Nginx启动成功，请访问http:&#x2F;&#x2F;$ADDR:80&quot;</span><br><span class="line">        else</span><br><span class="line">              echo &quot;Nginx启动失败！！！&quot;</span><br><span class="line">              exit 1</span><br><span class="line">fi</span><br><span class="line"> </span><br><span class="line"> </span><br><span class="line">#Start installing MySQL5.7！</span><br><span class="line">echo &quot;开始下载MySQL二进制安装包，请稍等...&quot;</span><br><span class="line">if [ -z &quot;$MAR&quot; ]</span><br><span class="line">                then</span><br><span class="line">                        echo &quot;开始安装MySQL&quot;</span><br><span class="line">fi</span><br><span class="line">if [ -n &quot;$MAR&quot; ]</span><br><span class="line">               then</span><br><span class="line">                        rpm -e mariadb-libs --nodeps &amp;&amp; echo &quot;卸载mariadb成功！正式安装MySQL&quot;</span><br><span class="line">fi</span><br><span class="line"> </span><br><span class="line">cd $ML || &#123;</span><br><span class="line">    echo &quot;进入目录失败！！！&quot;</span><br><span class="line">    exit 1</span><br><span class="line">&#125;</span><br><span class="line"> </span><br><span class="line">#wget https:&#x2F;&#x2F;cdn.mysql.com&#x2F;&#x2F;Downloads&#x2F;MySQL-5.7&#x2F;mysql-5.7.32-linux-glibc2.12-x86_64.tar.gz &amp;&gt; &#x2F;dev&#x2F;null &amp;&amp; &#123;</span><br><span class="line">wget https:&#x2F;&#x2F;cdn.mysql.com&#x2F;&#x2F;Downloads&#x2F;MySQL-5.7&#x2F;mysql-5.7.32-linux-glibc2.12-x86_64.tar.gz &amp;&amp; &#123;</span><br><span class="line">tar zxf mysql-5.7.32-linux-glibc2.12-x86_64.tar.gz  &amp;&amp; mv mysql-5.7.32-linux-glibc2.12-x86_64 &#x2F;usr&#x2F;local&#x2F;mysql</span><br><span class="line">cd &#x2F;usr&#x2F;local&#x2F;mysql&#x2F; &amp;&amp; mkdir data &amp;&amp; mkdir log &amp;&amp; echo &quot;export PATH&#x3D;$PATH:&#x2F;usr&#x2F;local&#x2F;mysql&#x2F;bin&quot; &gt;&gt; &#x2F;etc&#x2F;profile</span><br><span class="line">source &#x2F;etc&#x2F;profile &amp;&amp; groupadd mysql &amp;&amp; useradd -r -g mysql -s &#x2F;bin&#x2F;false mysql</span><br><span class="line">&#125;</span><br><span class="line">cat &lt;&lt; EOF &gt;&#x2F;etc&#x2F;my.cnf</span><br><span class="line">[client]  </span><br><span class="line">socket&#x3D;&#x2F;usr&#x2F;local&#x2F;mysql&#x2F;mysql.sock  </span><br><span class="line">[mysqld]  </span><br><span class="line">basedir&#x3D;&#x2F;usr&#x2F;local&#x2F;mysql  </span><br><span class="line">datadir&#x3D;&#x2F;usr&#x2F;local&#x2F;mysql&#x2F;data  </span><br><span class="line">pid-file&#x3D;&#x2F;usr&#x2F;local&#x2F;mysql&#x2F;data&#x2F;mysqld.pid  </span><br><span class="line">socket&#x3D;&#x2F;usr&#x2F;local&#x2F;mysql&#x2F;mysql.sock  </span><br><span class="line">log_error&#x3D;&#x2F;usr&#x2F;local&#x2F;mysql&#x2F;log&#x2F;mysql.err</span><br><span class="line">EOF</span><br><span class="line">if [ ! -d &#x2F;etc&#x2F;my.cnf ]</span><br><span class="line">                then</span><br><span class="line">                        chmod 750 data&#x2F; &amp;&amp; chown -R mysql . &amp;&amp; chgrp -R mysql . &amp;&amp; bin&#x2F;mysqld --initialize --user&#x3D;mysql &amp;&amp; cp &#x2F;usr&#x2F;local&#x2F;mysql&#x2F;support-files&#x2F;mysql.server &#x2F;etc&#x2F;init.d&#x2F;mysqld &amp;&amp; service mysqld start &amp;&gt; &#x2F;dev&#x2F;null</span><br><span class="line">                else</span><br><span class="line">                         echo &quot;错误！！！&quot;</span><br><span class="line">fi</span><br><span class="line">if [ $? -eq &quot;0&quot; ]</span><br><span class="line">    then</span><br><span class="line">        echo &quot;MySQL正式安装完成杀青！&quot;</span><br><span class="line">    else</span><br><span class="line">        echo &quot;MySQL安装失败！！！&quot;</span><br><span class="line">        exit 1</span><br><span class="line">fi</span><br><span class="line">#PHP install sccessy</span><br><span class="line">cp -frp &#x2F;usr&#x2F;lib64&#x2F;libldap* &#x2F;usr&#x2F;lib&#x2F;</span><br><span class="line">yum -y install libxml2-devel libcurl-devel libpng libpng-devel libpng libpng-devel freetype freetype-devel  openldap openldap-devel openssl-devel bzip2-devel &amp;&gt; &#x2F;dev&#x2F;null</span><br><span class="line">if [ $? -eq 0 ]</span><br><span class="line">        then</span><br><span class="line">                echo &quot;依赖包安装成功！！！&quot;</span><br><span class="line">        else</span><br><span class="line">                echo &quot;依赖包安装失败！！！&quot;</span><br><span class="line">fi</span><br><span class="line">cd $ML || &#123;</span><br><span class="line">        echo &quot;进入目录失败！！！&quot;</span><br><span class="line">        exit 1</span><br><span class="line">&#125;</span><br><span class="line">wget ftp:&#x2F;&#x2F;mcrypt.hellug.gr&#x2F;pub&#x2F;crypto&#x2F;mcrypt&#x2F;libmcrypt&#x2F;libmcrypt-2.5.7.tar.gz &amp;&gt; &#x2F;dev&#x2F;null  &amp;&amp; &#123;</span><br><span class="line">tar zxf libmcrypt-2.5.7.tar.gz &amp;&amp; cd libmcrypt-2.5.7&#x2F; &amp;&amp; .&#x2F;configure --prefix&#x3D;&#x2F;usr&#x2F;local&#x2F;libmcrypt &amp;&gt; &#x2F;dev&#x2F;null &amp;&amp; make &amp;&gt; &#x2F;dev&#x2F;null &amp;&amp; make install &amp;&gt; &#x2F;dev&#x2F;null</span><br><span class="line">&#125;</span><br><span class="line">if [ $? -eq 0 ]</span><br><span class="line">        then</span><br><span class="line">                echo &quot;Libmcrypt安装成功！&quot;</span><br><span class="line">        else</span><br><span class="line">                echo &quot;Libmcrypt-ERROR!&quot;</span><br><span class="line">        exit 1</span><br><span class="line">fi</span><br><span class="line"># PHP install</span><br><span class="line">cd $ML || &#123;</span><br><span class="line">        echo &quot;进入目录失败！！！&quot;</span><br><span class="line">        exit 1</span><br><span class="line">&#125;</span><br><span class="line">wget http:&#x2F;&#x2F;mirrors.sohu.com&#x2F;php&#x2F;php-5.6.27.tar.gz &amp;&gt; &#x2F;dev&#x2F;null &amp;&amp; &#123;</span><br><span class="line">tar zxf php-5.6.27.tar.gz &amp;&amp; cd php-5.6.27&#x2F; &amp;&amp;  .&#x2F;configure --prefix&#x3D;&#x2F;usr&#x2F;local&#x2F;php --with-mysql&#x3D;mysqlnd --with-pdo-mysql&#x3D;mysqlnd --with-mysqli&#x3D;mysqlnd --with-openssl --enable-fpm --enable-sockets --enable-sysvshm --enable-mbstring --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir&#x3D;&#x2F;usr --enable-xml --with-mhash --with-mcrypt&#x3D;&#x2F;usr&#x2F;local&#x2F;libmcrypt --with-config-file-path&#x3D;&#x2F;etc --with-config-file-scan-dir&#x3D;&#x2F;etc&#x2F;php.d --with-bz2 --enable-maintainer-zts  &amp;&gt; &#x2F;dev&#x2F;null</span><br><span class="line">&#125;</span><br><span class="line">if [ $? -eq 0 ]</span><br><span class="line">            then</span><br><span class="line">                 make &amp;&gt; &#x2F;dev&#x2F;null  &amp;&amp; make install &amp;&gt; &#x2F;dev&#x2F;null  &amp;&amp;  echo &quot;PHP编译安装成功,正在配置请稍等....&quot;</span><br><span class="line">            else</span><br><span class="line">                 echo &quot;PHP安装失败&quot;</span><br><span class="line">fi</span><br><span class="line">cd $PML || &#123;</span><br><span class="line">                echo &quot;进入目录失败！！！&quot;</span><br><span class="line">                exit 1</span><br><span class="line">&#125;</span><br><span class="line">cp php.ini-production &#x2F;etc&#x2F;php.ini &amp;&amp; &#123;</span><br><span class="line">cp sapi&#x2F;fpm&#x2F;init.d.php-fpm &#x2F;etc&#x2F;init.d&#x2F;php-fpm &amp;&amp; chmod +x &#x2F;etc&#x2F;init.d&#x2F;php-fpm &amp;&amp; chkconfig --add php-fpm &amp;&amp; chkconfig php-fpm on</span><br><span class="line">&#125;</span><br><span class="line">if [ $? -eq 0 ]</span><br><span class="line">                        then</span><br><span class="line">                                cp &#x2F;usr&#x2F;local&#x2F;php&#x2F;etc&#x2F;php-fpm.conf.default &#x2F;usr&#x2F;local&#x2F;php&#x2F;etc&#x2F;php-fpm.conf &amp;&amp; echo &quot;复制主配置成功&quot;</span><br><span class="line">                        else</span><br><span class="line">                                echo &quot;PHP权限失败，请重试！&quot;</span><br><span class="line">fi</span><br><span class="line">if [ ! -d &#x2F;usr&#x2F;local&#x2F;php&#x2F;etc&#x2F;php-fpm.conf ]</span><br><span class="line">        then</span><br><span class="line">                sed -i &#39;s#;pid &#x3D; run&#x2F;php-fpm.pid#pid &#x3D; run&#x2F;php-fpm.pid#g&#39; &#x2F;usr&#x2F;local&#x2F;php&#x2F;etc&#x2F;php-fpm.conf</span><br><span class="line">                sed -i &#39;s&#x2F;listen &#x3D; 127.0.0.1:9000&#x2F;listen &#x3D; 127.0.0.1:9000&#x2F;g&#39; &#x2F;usr&#x2F;local&#x2F;php&#x2F;etc&#x2F;php-fpm.conf</span><br><span class="line">                sed -i &#39;s&#x2F;pm.max_children &#x3D; 5&#x2F;pm.max_children &#x3D; 300&#x2F;g&#39; &#x2F;usr&#x2F;local&#x2F;php&#x2F;etc&#x2F;php-fpm.conf</span><br><span class="line">                sed -i &#39;s&#x2F;pm.start_servers &#x3D; 2&#x2F;pm.start_servers &#x3D; 20&#x2F;g&#39; &#x2F;usr&#x2F;local&#x2F;php&#x2F;etc&#x2F;php-fpm.conf</span><br><span class="line">                sed -i &#39;s&#x2F;pm.min_spare_servers &#x3D; 1&#x2F;pm.min_spare_servers &#x3D; 20&#x2F;g&#39; &#x2F;usr&#x2F;local&#x2F;php&#x2F;etc&#x2F;php-fpm.conf</span><br><span class="line">                sed -i &#39;s&#x2F;pm.max_spare_servers &#x3D; 3&#x2F;pm.max_spare_servers &#x3D; 100&#x2F;g&#39; &#x2F;usr&#x2F;local&#x2F;php&#x2F;etc&#x2F;php-fpm.conf</span><br><span class="line">        else</span><br><span class="line">                echo &quot;NONONO&quot;</span><br><span class="line">fi</span><br><span class="line">if [ $? -eq 0 ]</span><br><span class="line">                        then</span><br><span class="line">                                systemctl start php-fpm &amp;&amp; echo &quot;PHP启动成功&quot;</span><br><span class="line">                        else</span><br><span class="line">                                echo &quot;启动PHP失败&quot;</span><br><span class="line">fi</span><br><span class="line">#配置nginx解析php</span><br><span class="line">if [ ! -d &#x2F;usr&#x2F;local&#x2F;nginx&#x2F;conf&#x2F;nginx.conf ]</span><br><span class="line">        then</span><br><span class="line">               sed -i &#39;s&#x2F;index  index.html index.htm;&#x2F;index  index.php index.html index.htm;&#x2F;g&#39; &#x2F;usr&#x2F;local&#x2F;nginx&#x2F;conf&#x2F;nginx.conf</span><br><span class="line">               sed -i &#39;s&#x2F;#    root           html;&#x2F;    root           html;&#x2F;g&#39; &#x2F;usr&#x2F;local&#x2F;nginx&#x2F;conf&#x2F;nginx.conf</span><br><span class="line">               sed -i &#39;s&#x2F;#    fastcgi_pass   127.0.0.1:9000;&#x2F;    fastcgi_pass   127.0.0.1:9000;&#x2F;g&#39; &#x2F;usr&#x2F;local&#x2F;nginx&#x2F;conf&#x2F;nginx.conf</span><br><span class="line">               sed -i &#39;s&#x2F;#    fastcgi_index  index.php;&#x2F;    fastcgi_index  index.php;&#x2F;g&#39; &#x2F;usr&#x2F;local&#x2F;nginx&#x2F;conf&#x2F;nginx.conf</span><br><span class="line">               sed -i &#39;s*#    fastcgi_param  SCRIPT_FILENAME  &#x2F;scripts$fastcgi_script_name;*    fastcgi_param  SCRIPT_FILENAME  &#x2F;scripts$fastcgi_script_name;*g&#39; &#x2F;usr&#x2F;local&#x2F;nginx&#x2F;conf&#x2F;nginx.conf</span><br><span class="line">               sed -i &#39;s&#x2F;#    include        fastcgi_params;&#x2F;    include        fastcgi.conf;&#x2F;g&#39; &#x2F;usr&#x2F;local&#x2F;nginx&#x2F;conf&#x2F;nginx.conf</span><br><span class="line">               sed -i &#39;71d&#39; &#x2F;usr&#x2F;local&#x2F;nginx&#x2F;conf&#x2F;nginx.conf &amp;&amp; sed -i &#39;N;70a&#125;&#39; &#x2F;usr&#x2F;local&#x2F;nginx&#x2F;conf&#x2F;nginx.conf</span><br><span class="line">               sed -i &#39;65d&#39; &#x2F;usr&#x2F;local&#x2F;nginx&#x2F;conf&#x2F;nginx.conf &amp;&amp; sed -i &#39;N;64alocation ~ \\.php$ &#123;&#39; &#x2F;usr&#x2F;local&#x2F;nginx&#x2F;conf&#x2F;nginx.conf</span><br><span class="line">        else</span><br><span class="line">               echo &quot;解析PHP失败！！！&quot;</span><br><span class="line">fi</span><br><span class="line">touch &#x2F;usr&#x2F;local&#x2F;nginx&#x2F;html&#x2F;phptest.php</span><br><span class="line">cat &lt;&lt; EOF &gt;&#x2F;usr&#x2F;local&#x2F;nginx&#x2F;html&#x2F;phptest.php</span><br><span class="line">&lt;?php</span><br><span class="line">phpinfo();</span><br><span class="line">?&gt;</span><br><span class="line">EOF</span><br><span class="line">if [ ! -d &#x2F;usr&#x2F;local&#x2F;nginx&#x2F;html&#x2F;phptest.php ]</span><br><span class="line">    then</span><br><span class="line">        nginx -s reload &amp;&amp; systemctl restart php-fpm</span><br><span class="line">    else</span><br><span class="line">        echo &quot;测试目录文件失败&quot;</span><br><span class="line">fi</span><br><span class="line">wget -O &#x2F;etc&#x2F;yum.repos.d&#x2F;epel.repo http:&#x2F;&#x2F;mirrors.aliyun.com&#x2F;repo&#x2F;epel-7.repo  &amp;&gt; &#x2F;dev&#x2F;null &amp;&amp; yum install -y sl &amp;&gt; &#x2F;dev&#x2F;null</span><br><span class="line">sl</span><br><span class="line">if [ $? -eq 0 ]</span><br><span class="line">        then</span><br><span class="line">                echo &quot;LNMP安装成功，请您访问http:&#x2F;&#x2F;$ADDR&#x2F;phptest.php&quot;</span><br><span class="line">        else</span><br><span class="line">                echo &quot;安装失败&quot;</span><br><span class="line">fi</span><br><span class="line">if [ $? -eq 0 ]</span><br><span class="line">    then</span><br><span class="line">        echo &quot;LNMP安装成功，请您访问http:&#x2F;&#x2F;$ADDR&#x2F;phptest.php&quot;</span><br><span class="line">    else</span><br><span class="line">        echo &quot;安装失败&quot;</span><br><span class="line">fi</span><br><span class="line">###################################################################################################This is a lnmp-install</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"></span><br></pre></td></tr></table></figure>
      
    </div>
    <footer class="article-footer">
      <a data-url="http://example.com/2020/11/19/Centos7%E4%B8%8A%E4%BD%BF%E7%94%A8shell%E8%84%9A%E6%9C%AC%E4%B8%80%E9%94%AE%E5%AE%89%E8%A3%85%E9%83%A8%E7%BD%B2lnmp/" data-id="ckho8bj1o0001zkvj0319eu94" class="article-share-link">
        分享
      </a>
      
    </footer>

  </div>

  
  
  <nav class="article-nav">
    
    
      <a href="/2020/11/19/nginx%E9%85%8D%E7%BD%AE%E6%96%87%E4%BB%B6/" class="article-nav-link">
        <strong class="article-nav-caption">后一篇</strong>
        <div class="article-nav-title">nginx配置文件</div>
      </a>
    
  </nav>


  

  
  
  
  

</article>
</section>
  <footer class="footer">
  <div class="outer">
    <div class="float-right">
      <ul class="list-inline">
  
    <li><i class="fe fe-smile-alt"></i> <span id="busuanzi_value_site_uv"></span></li>
  
    <li><i class="fe fe-bookmark"></i> <span id="busuanzi_value_page_pv"></span></li>
  
</ul>
    </div>
    <ul class="list-inline">
      <li>&copy; 2020 lnsix的个人博客</li>
      <li>Powered by <a href="http://hexo.io/" target="_blank">Hexo</a></li>
      <li>Theme  <a target="_blank" rel="noopener" href="https://github.com/zhwangart/hexo-theme-ocean">Ocean</a></li>
    </ul>
  </div>
</footer>

</main>
<aside class="sidebar">
  <button class="navbar-toggle"></button>
<nav class="navbar">
  
    <div class="logo">
      <a href="/"><img src="/images/hexo.svg" alt="lnsix的个人博客"></a>
    </div>
  
  <ul class="nav nav-main">
    
      <li class="nav-item">
        <a class="nav-item-link" href="/">Home</a>
      </li>
    
      <li class="nav-item">
        <a class="nav-item-link" href="/archives">Archives</a>
      </li>
    
      <li class="nav-item">
        <a class="nav-item-link" href="/gallery">Gallery</a>
      </li>
    
      <li class="nav-item">
        <a class="nav-item-link" href="/about">About</a>
      </li>
    
    <li class="nav-item">
      <a class="nav-item-link nav-item-search" title="搜索">
        <i class="fe fe-search"></i>
        搜索
      </a>
    </li>
  </ul>
</nav>
<nav class="navbar navbar-bottom">
  <ul class="nav">
    <li class="nav-item">
      <div class="totop" id="totop">
  <i class="fe fe-rocket"></i>
</div>
    </li>
    <li class="nav-item">
      
        <a class="nav-item-link" target="_blank" href="/atom.xml" title="RSS Feed">
          <i class="fe fe-feed"></i>
        </a>
      
    </li>
  </ul>
</nav>
<div class="search-form-wrap">
  <div class="local-search local-search-plugin">
  <input type="search" id="local-search-input" class="local-search-input" placeholder="Search...">
  <div id="local-search-result" class="local-search-result"></div>
</div>
</div>
</aside>

<script src="/js/jquery-2.0.3.min.js"></script>


<script src="/js/jquery.justifiedGallery.min.js"></script>


<script src="/js/lazyload.min.js"></script>


<script src="/js/busuanzi-2.3.pure.min.js"></script>


  
<script src="/fancybox/jquery.fancybox.min.js"></script>




  
<script src="/js/tocbot.min.js"></script>

  <script>
    // Tocbot_v4.7.0  http://tscanlin.github.io/tocbot/
    tocbot.init({
      tocSelector: '.tocbot',
      contentSelector: '.article-entry',
      headingSelector: 'h1, h2, h3, h4, h5, h6',
      hasInnerContainers: true,
      scrollSmooth: true,
      positionFixedSelector: '.tocbot',
      positionFixedClass: 'is-position-fixed',
      fixedSidebarOffset: 'auto',
    });
  </script>



<script src="/js/ocean.js"></script>


</body>
</html>